package com.darly.chinese.db.book.table;


import com.darly.chinese.db.book.database.BookDataBase;
import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.structure.BaseModel;

import java.util.List;

@Table(database = BookDataBase.class)
public class DownloadTaskBean extends BaseModel {
    public static final int STATUS_LOADING = 1;
    public static final int STATUS_WAIT = 2;
    public static final int STATUS_PAUSE = 3;
    public static final int STATUS_ERROR = 4;
    public static final int STATUS_FINISH = 5;

    //任务名称 -> 名称唯一不重复
    @PrimaryKey
    @Column
    private String taskName;
    //所属的bookId(外健)
    @Column
    private String bookId;

    //章节的下载进度,默认为初始状态
    @Column
    private int currentChapter = 0;
    //最后的章节
    @Column
    private int lastChapter = 0;
    //状态:正在下载、下载完成、暂停、等待、下载错误。
    @Column
    private volatile int status = STATUS_WAIT;
    //总大小 -> (完成之后才会赋值)
    @Column
    private long size = 0;


    private List<BookChapterBean> bookChapterList;

    public String getBookId() {
        return bookId;
    }

    public void setBookId(String bookId) {
        this.bookId = bookId;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;

    }

    public void setBookChapters(List<BookChapterBean> beans) {
        bookChapterList = beans;
    }

    public List<BookChapterBean> getBookChapters() {
        return bookChapterList;
    }

    public int getCurrentChapter() {
        return currentChapter;
    }

    public void setCurrentChapter(int current) {
        this.currentChapter = current;
    }

    public int getLastChapter() {
        return lastChapter;
    }

    public void setLastChapter(int lastChapter) {
        this.lastChapter = lastChapter;
    }

    //多线程访问的问题，所以需要同步机制
    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

}
